/*
 *  TI_Pixelator.h
 *
 *	Pixelates an image into blocks (pixels) of set dimensions.
 *
 *  Created by Pat Long (plong0) on 02/02/09.
 *  Copyright 2009 Tangible Interaction Inc. All rights reserved.
 *
 */
#ifndef _TI_PIXELATOR
#define _TI_PIXELATOR

#include "ofMain.h"

#define DEFAULT_PIXEL_WIDTH 10
#define DEFAULT_PIXEL_HEIGHT 10

class TI_Pixelator{
private:
	ofImage* originalImage;
	ofImage* pixelatedImage;
	int pixelWidth, pixelHeight;
	
	void init(int pixelWidth=DEFAULT_PIXEL_WIDTH, int pixelHeight=DEFAULT_PIXEL_HEIGHT);
	void refreshPixels();
	
public:
	int pixelRows, pixelCols;
	int*** pixels;
	
	TI_Pixelator();
	TI_Pixelator(int pixelWidth, int pixelHeight);
	~TI_Pixelator();
	
	void setPixelWidth(int pixelWidth, bool refresh=true);
	void setPixelHeight(int pixelHeight, bool refresh=true);
	void setPixelSize(int pixelWidth, int pixelHeight, bool refresh=true);
	
	ofImage* pixelateImage(ofImage* originalImage);
	ofImage* pixelateScreen(int x, int y, int width, int height);
	ofImage* pixelateScreen(ofRectangle* area);
	
	void draw(int x=0, int y=0);
	void drawOriginal(int x=0, int y=0);
	void drawPixelated(int x=0, int y=0);
};

#endif
